{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "228438fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "A603 = pd.read_csv(\"../0603_0609/5G_F37_0603_0609.csv\")\n",
    "A610 = pd.read_csv(\"../0610_0616/5G_F37_0610_0616.csv\")\n",
    "A617 = pd.read_csv(\"../0617_0623/5G_F37_0617_0623.csv\")\n",
    "A624 = pd.read_csv(\"../0624_0630/5G_F37_0624_0630.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97dd89d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "A603['TimeStamp'] = A603['TimeStamp'].astype('datetime64[ns]')\n",
    "A610['TimeStamp'] = A610['TimeStamp'].astype('datetime64[ns]')\n",
    "A617['TimeStamp'] = A617['TimeStamp'].astype('datetime64[ns]')\n",
    "A624['TimeStamp'] = A624['TimeStamp'].astype('datetime64[ns]')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15624b2e",
   "metadata": {},
   "outputs": [],
   "source": [
    "A610.rename(columns={'TimeStamp': 'TimeStamp1'}, inplace=True)\n",
    "A617.rename(columns={'TimeStamp': 'TimeStamp2'}, inplace=True)\n",
    "A624.rename(columns={'TimeStamp': 'TimeStamp3'}, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "72852ea2",
   "metadata": {},
   "outputs": [],
   "source": [
    "date_range = pd.date_range(\"2021-06-03 00:00:00\",\"2021-06-09 23:00:00\",freq='H')\n",
    "date_range1 = pd.date_range(\"2021-06-10 00:00:00\",\"2021-06-16 23:00:00\",freq='H')\n",
    "date_range2 = pd.date_range(\"2021-06-17 00:00:00\",\"2021-06-23 23:00:00\",freq='H')\n",
    "date_range3 = pd.date_range(\"2021-06-24 00:00:00\",\"2021-06-30 23:00:00\",freq='H')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac52319b",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "new_index = pd.MultiIndex.from_product([A603['UserLabel'].unique(),date_range],names=['UserLabel','TimeStamp'])\n",
    "A603_date = pd.DataFrame(index=new_index).reset_index()\n",
    "A603_new = pd.merge(A603_date,A603,how='left',on=['UserLabel','TimeStamp'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e0030227",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = ['上行利用率PUSCH','下行利用率PDSCH','下行利用率PDCCH','有数据传输的RRC连接数','上行流量','下行流量']\n",
    "for i in range(6):\n",
    "    A = A603_new[[s[i]]]\n",
    "    B = A610_new[[s[i]]]\n",
    "    C = A617_new[[s[i]]]\n",
    "    D = A624_new[[s[i]]]\n",
    "    result = pd.concat([A,B,C,D], axis=1)\n",
    "    mean_re = result.mean(1)\n",
    "    dict_result = {'result':mean_re.index,s[i]:mean_re.values}\n",
    "    result = pd.DataFrame(dict_result)\n",
    "    mean = result[[s[i]]]\n",
    "    A701_new = pd.concat([A701_new,mean],axis=1)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py37",
   "language": "python",
   "name": "py37"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
